package com.happyfamily.springboot.crowdsourcingplatform.controller.guo;

import com.happyfamily.springboot.crowdsourcingplatform.annotation.OperationLogDetail;
import com.happyfamily.springboot.crowdsourcingplatform.enums.OperationType;
import com.happyfamily.springboot.crowdsourcingplatform.enums.OperationUnit;
import com.happyfamily.springboot.crowdsourcingplatform.service.guo.PictureService;
import com.happyfamily.springboot.crowdsourcingplatform.service.guo.ServiceProvidersService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/api-back/picture")
public class PictureController
{
	@Autowired
	private PictureService service;

	@RequestMapping("/addPicture")
	@ResponseBody
	@ApiOperation(value = "后端增加友情链接", notes = "后端增加友情链接")
	@OperationLogDetail(detail = "后端增加友情链接", level = 3, operationUnit = OperationUnit.USER, operationType = OperationType.INSERT)
	@PreAuthorize("hasAuthority('back:friendlink:add')")
	public String addPicture(HttpServletRequest request, MultipartFile file)
	{
		String str = "no";
		boolean flag = service.uploadPicture(request, file);
		if (flag)
		{
			str = "yes";
		}
		return str;

	}


}
